﻿@namespace Bit.BlazorUI
@inherits BitComponentBase

<div @ref="RootElement" @attributes="HtmlAttributes"
     id="@_Id"
     style="@StyleBuilder.Value"
     class="@ClassBuilder.Value"
     dir="@Dir?.ToString().ToLower()">
    <div style="@Styles?.RootContainer" class="bit-msg-rct @Classes?.RootContainer">
        <div style="@Styles?.Container" class="bit-msg-con @Classes?.Container">
            @if (HideIcon is false)
            {
                <div style="@Styles?.IconContainer" class="bit-msg-ict @Classes?.IconContainer" aria-hidden="true">
                    <i style="@Styles?.Icon" class="bit-msg-ico bit-icon bit-icon--@GetIconName() @Classes?.Icon" />
                </div>
            }

            <div style="@Styles?.ContentContainer" class="bit-msg-cnc@(_isExpanded ? " bit-msg-cnx": "") @Classes?.ContentContainer" role="@GetTextRole()">
                <div style="@Styles?.ContentWrapper" class="bit-msg-cnw @Classes?.ContentWrapper">
                    <div style="@Styles?.Content" class="bit-msg-cnt@(Multiline ? " bit-msg-mcn" : "") @Classes?.Content">
                        @(Content ?? ChildContent)
                    </div>
                </div>
            </div>
        </div>

        @if (Actions is not null && Multiline is false)
        {
            <div style="@Styles?.Actions" class="bit-msg-act @Classes?.Actions">@Actions</div>
        }

        @if (Truncate && Multiline is false)
        {
            <button style="@Styles?.ExpanderButton" class="bit-msg-exb @Classes?.ExpanderButton" @onclick="ToggleExpand" type="button">
                <i style="@Styles?.ExpanderIcon" class="bit-msg-exi bit-icon bit-icon--@(_isExpanded ? (CollapseIcon ?? "DoubleChevronUp") : (ExpandIcon ?? "DoubleChevronUp bit-ico-r180")) @Classes?.ExpanderIcon" aria-hidden="true" />
            </button>
        }

        @if (OnDismiss.HasDelegate)
        {
            <button style="@Styles?.DismissButton" class="bit-msg-dmb @Classes?.DismissButton" @onclick="OnDismiss" type="button">
                <i style="@Styles?.DismissIcon" class="bit-msg-dmi bit-icon bit-icon--@(DismissIcon ?? "Cancel") @Classes?.DismissIcon" aria-hidden="true" />
            </button>
        }
    </div>

    @if (Actions is not null && Multiline)
    {
        <div style="@Styles?.Actions" class="bit-msg-act bit-msg-mac @Classes?.Actions">@Actions</div>
    }
</div>
